package com.yang.action;

import com.yang.entity.Ads;
import com.yang.service.AdsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;

@WebServlet("/saveAds")
public class AdsSaveAction extends HttpServlet {
    AdsService adsService = new AdsService();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Ads ads = new Ads();
        String title = req.getParameter("title");
        ads.setTitle(title);
        String remark = req.getParameter("remark");
        ads.setRemark(remark);
        String img = req.getParameter("img");
        ads.setImg(img);
        String url = req.getParameter("url");
        ads.setUrl(url);
        String target = req.getParameter("target");
        ads.setTarget(target);
        int num = adsService.saveAds(ads);
        resp.setContentType("text/text;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print(num);
        out.flush();
        out.close();
    }
}

